// Program: udev
// Description: Creates a filesystem type called devfs, and mounts it at
//              /dev/. This filesystem handles all devices.

//
// main.cc -- Defines the main startup routine, and runloop.
//

#include <jimix/FileDescriptor.h>
#include <jimix/Process.h>
#include <jimix/MonitorDriver.h>
#include <jimix/resource.h>
#include <jimix/Filesystem.h>
#include <jimix/Directory.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "UdevFilesystem.h"

#undef errno
extern int errno;

extern "C" void yield();

int main(char argc, char **argv)
{
  UdevFilesystem *devfs = new UdevFilesystem();

  // Get the root filesystem.
  u32int root = requestResource("Filesystem");
  u32int dev = callResource(root, Filesystem_IF::traverse, "/dev");
  
  callResource(dev, Directory_IF::mount, devfs->getFilesystem());
  
  for(;;)
    yield();
}
